exports.articles = (req,res)=> {
  let article = global.dbHelper.getModel('article'); 

  if(req.method == 'POST'){
	  let blogTitle = req.body.blogTitle,
	      blogText = req.body.blogText,  
	      blogType  = req.body.blogType ,
	      blogAuthor  = req.body.blogAuthor,
	      coverImg  = req.body.coverImg ,
	      watchNum = req.body.watchNum;
	      console.log(watchNum)
	   
	  let time=new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()+' '+new Date().getHours()+':'+new Date().getMinutes()+':'+new Date().getSeconds();
	  
	  article.create({
	 	  blogTitle:blogTitle,
	 	  coverImg:coverImg,
	 	  blogType:blogType,
	   	  blogAuthor:blogAuthor,
	   	  blogText:blogText,
	   	  time:time,
	   	  watchNum:watchNum
	  },(error,doc) =>{
	 	 if(error){
	 	 	logger.error("创建失败:"+error)
	 	 	res.json({
	 	 		"code": 500,
	 	 		"msg":"创建失败"
	 	 	})
	 	 }else{
	 	 	res.json({
	 	 		"code": 200,
	 	 		"msg": "创建成功"
	 	 	})
	 	 }
	  })
	}else{
       article.find({},(error,doc) =>{
	 	 if(error){
	 	 	logger.error("查找失败:"+error)
	 	 	res.json({
	 	 		"code": 500,
	 	 		"msg":"查找失败"
	 	 	})
	 	 }else{
	 	 	res.json({
	 	 		"code": 200,
	 	 		"msg": "查找成功",
	 	 		"result":doc
	 	 	})
	 	 }
	  }).sort({"time":-1})
	}
 }
